Esempio n. 1
0
        private string GetScriptPath(EnvironmentView view)
        {
            if (view == null)
            {
                return(null);
            }

            string path;

            lock (_cachedScriptPaths) {
                if (_cachedScriptPaths.TryGetValue(view, out path))
                {
                    return(path);
                }
            }

            try {
                path = _uiThread.Invoke(() => PythonInteractiveEvaluator.GetScriptsPath(
                                            _site,
                                            view.Description,
                                            view.Factory.Configuration,
                                            false
                                            ));
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                view.Dispatcher.BeginInvoke((Action)(() => ex.ReportUnhandledException(_site, GetType())), DispatcherPriority.ApplicationIdle);
                path = null;
            }

            lock (_cachedScriptPaths) {
                _cachedScriptPaths[view] = path;
            }
            return(path);
        }
Esempio n. 2
0
        private void EnvironmentsView_CurrentChanged(object sender, EventArgs e)
        {
            EnvironmentView item = _environmentsView.View.CurrentItem as EnvironmentView;

            if (item == null)
            {
                lock (_extensions)
                {
                    _extensions.Clear();
                }
                return;
            }
            OnViewSelected(item);
            var oldSelect = _extensionsView.View.CurrentItem?.GetType();
            var newSelect = oldSelect == null ? null :
                            item.Extensions?.FirstOrDefault(ext => ext != null && ext.GetType().IsEquivalentTo(oldSelect));

            lock (_extensions)
            {
                _extensions.Clear();
                foreach (var ext in item.Extensions.MaybeEnumerate())
                {
                    _extensions.Add(ext);
                }
                if (newSelect != null)
                {
                    _extensionsView.View.MoveCurrentTo(newSelect);
                }
                else
                {
                    _extensionsView.View.MoveCurrentToFirst();
                }
            }
        }
Esempio n. 3
0
        private void SetIPythonEnabled(EnvironmentView view, bool enable)
        {
            var path = GetScriptPath(view);

            if (!EnsureScriptDirectory(path))
            {
                return;
            }

            try {
                path = PathUtils.GetAbsoluteFilePath(path, "mode.txt");
                if (enable)
                {
                    File.WriteAllText(path, Strings.ReplScriptPathIPythonModeTxtContents);
                }
                else
                {
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                TaskDialog.ForException(_site, ex, issueTrackerUrl: Strings.IssueTrackerUrl).ShowModal();
            }
        }
Esempio n. 4
0
            public T GetExtensionOrAssert <T>(EnvironmentView view) where T : IEnvironmentViewExtension
            {
                var ext = GetExtensionOrDefault <T>(view);

                Assert.IsNotNull(ext, "Unable to get " + typeof(T).Name);
                return(ext);
            }
Esempio n. 5
0
        private void SetIPythonEnabled(EnvironmentView view, bool enable)
        {
            var path = GetScriptsPath(view);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            if (enable)
            {
                File.WriteAllText(Path.Combine(path, "__test_mode.txt"), "# Contents of the file");
            }
            else
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }
Esempio n. 6
0
        private static string GetPathEntries(EnvironmentView view)
        {
            if (!Directory.Exists(view?.PrefixPath))
            {
                return(null);
            }

            return(string.Join(";", PathSuffixes
                               .Select(s => PathUtils.GetAbsoluteDirectoryPath(view.PrefixPath, s))
                               .Where(Directory.Exists)));
        }
Esempio n. 7
0
            public T GetExtensionOrDefault <T>(EnvironmentView view) where T : IEnvironmentViewExtension
            {
                var ext = _proxy.Invoke(() => view.Extensions.OfType <T>().FirstOrDefault());

                if (ext != null)
                {
                    // Get the WpfObject to ensure it is constructed on the
                    // UI thread.
                    var fe = _proxy.Invoke(() => ext.WpfObject);
                }
                return(ext);
            }
Esempio n. 8
0
        internal static string GetScriptsPath(EnvironmentView view)
        {
            if (view == null) {
                return null;
            }

            return Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                "Visual Studio " + AssemblyVersionInfo.VSName,
                "Python Scripts",
                view.Description
            );
        }
Esempio n. 9
0
        internal static string GetScriptsPath(EnvironmentView view)
        {
            if (view == null)
            {
                return(null);
            }

            return(Path.Combine(
                       Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                       "Visual Studio " + AssemblyVersionInfo.VSName,
                       "Python Scripts",
                       view.Description
                       ));
        }
Esempio n. 10
0
        private string GetScriptPath(EnvironmentView view)
        {
            if (view == null)
            {
                return(null);
            }

            return(PythonInteractiveEvaluator.GetScriptsPath(
                       _site,
                       view.Description,
                       view.Factory.Configuration,
                       false
                       ));
        }
Esempio n. 11
0
        private void ConfigurationExtension_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            EnvironmentView view = e.NewValue as EnvironmentView;

            if (view != null)
            {
                ConfigurationEnvironmentView current = Subcontext.DataContext as ConfigurationEnvironmentView;
                if (current == null || current.EnvironmentView != view)
                {
                    ConfigurationEnvironmentView cev = new ConfigurationEnvironmentView(view);
                    _provider.ResetConfiguration(cev);
                    Subcontext.DataContext = cev;
                }
            }
        }
Esempio n. 12
0
        private void IsIPythonModeEnabled_Loaded(object sender, RoutedEventArgs e)
        {
            EnvironmentView ev = (e.Source as FrameworkElement)?.DataContext as EnvironmentView;

            if (ev == null)
            {
                return;
            }

            e.Handled = true;
            if (ev.IsIPythonModeEnabled.HasValue)
            {
                return;
            }

            ev.IsIPythonModeEnabled = ev.IPythonModeEnabledGetter?.Invoke(ev) ?? false;
        }
Esempio n. 13
0
        private bool QueryIPythonEnabled(EnvironmentView view)
        {
            var path = GetScriptsPath(view);

            return(!string.IsNullOrEmpty(path) && !File.Exists(Path.Combine(path, "__test_mode.txt")));
        }
Esempio n. 14
0
 public void removeEnvironmentView(EnvironmentView ev)
 {
     views.Remove(ev);
 }
Esempio n. 15
0
 public void SetView(EnvironmentView environmentView)
 {
     m_environmentLightingView = environmentView.environmentLightingView;
 }
Esempio n. 16
0
 public void addEnvironmentView(EnvironmentView ev)
 {
     views.Add(ev);
 }
Esempio n. 17
0
        private bool QueryIPythonEnabled(EnvironmentView view)
        {
            var path = GetScriptPath(view);

            return(path != null && File.Exists(PathUtils.GetAbsoluteFilePath(path, "mode.txt")));
        }
 public void removeEnvironmentView(EnvironmentView ev)
 {
     views.Remove(ev);
 }
 public void addEnvironmentView(EnvironmentView ev)
 {
     views.Add(ev);
 }
Esempio n. 20
0
 public void SetView(EnvironmentView environmentView)
 {
     m_environmentCloud.SetView(environmentView.environmentCloudView);
     m_environmentRain.SetView(environmentView.environmentRainView);
     m_environmentLightning.SetView(environmentView.environmentLightningView);
 }
Esempio n. 21
0
 public ConfigurationEnvironmentView(EnvironmentView view)
 {
     _view = view;
 }