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); }
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(); } } }
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(); } }
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); }
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); } } }
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))); }
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); }
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 ); }
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 )); }
private string GetScriptPath(EnvironmentView view) { if (view == null) { return(null); } return(PythonInteractiveEvaluator.GetScriptsPath( _site, view.Description, view.Factory.Configuration, false )); }
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; } } }
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; }
private bool QueryIPythonEnabled(EnvironmentView view) { var path = GetScriptsPath(view); return(!string.IsNullOrEmpty(path) && !File.Exists(Path.Combine(path, "__test_mode.txt"))); }
public void removeEnvironmentView(EnvironmentView ev) { views.Remove(ev); }
public void SetView(EnvironmentView environmentView) { m_environmentLightingView = environmentView.environmentLightingView; }
public void addEnvironmentView(EnvironmentView ev) { views.Add(ev); }
private bool QueryIPythonEnabled(EnvironmentView view) { var path = GetScriptPath(view); return(path != null && File.Exists(PathUtils.GetAbsoluteFilePath(path, "mode.txt"))); }
public void SetView(EnvironmentView environmentView) { m_environmentCloud.SetView(environmentView.environmentCloudView); m_environmentRain.SetView(environmentView.environmentRainView); m_environmentLightning.SetView(environmentView.environmentLightningView); }
public ConfigurationEnvironmentView(EnvironmentView view) { _view = view; }