public MainViewModel(IServiceLocator serviceLocator, ITelemetryProvider telemetryProvider, ICommandProvider commands, IApplicationSettings settings, NuGetViewModel nugetViewModel)
        {
            _serviceLocator    = serviceLocator;
            _telemetryProvider = telemetryProvider;
            _commands          = commands;
            Settings           = settings;
            _telemetryProvider.Initialize(_currentVersion.ToString(), settings);
            _telemetryProvider.LastErrorChanged += () =>
            {
                OnPropertyChanged(nameof(LastError));
                OnPropertyChanged(nameof(HasError));
            };

            NuGet = nugetViewModel;
            NuGetConfiguration = new NuGetConfiguration(NuGet.GlobalPackageFolder, NuGetPathVariableName);

            NewDocumentCommand          = commands.Create(CreateNewDocument);
            CloseCurrentDocumentCommand = commands.CreateAsync(CloseCurrentDocument);
            ClearErrorCommand           = commands.Create(() => _telemetryProvider.ClearLastError());
            ReportProblemCommand        = commands.Create(ReportProblem);
            EditUserDocumentPathCommand = commands.Create(EditUserDocumentPath);

            _editorFontSize = Settings.EditorFontSize;

            DocumentRoot = CreateDocumentRoot();

            OpenDocuments = new ObservableCollection <OpenDocumentViewModel>();
            OpenDocuments.CollectionChanged += (sender, args) => OnPropertyChanged(nameof(HasNoOpenDocuments));
        }
        public MainViewModel(IServiceLocator serviceLocator, ITelemetryProvider telemetryProvider, ICommandProvider commands, NuGetViewModel nugetViewModel)
        {
            _serviceLocator    = serviceLocator;
            _telemetryProvider = telemetryProvider;
            _telemetryProvider.Initialize(_currentVersion.ToString());
            _telemetryProvider.LastErrorChanged += () => OnPropertyChanged(nameof(LastError));

            NuGet = nugetViewModel;
            NuGetConfiguration = new NuGetConfiguration(NuGet.GlobalPackageFolder, NuGetPathVariableName);
            RoslynHost         = new RoslynHost(NuGetConfiguration, new[]
            {
                // TODO: xplat
                Assembly.Load("RoslynPad.Roslyn.Windows"),
                Assembly.Load("RoslynPad.Editor.Windows")
            });

            NewDocumentCommand          = commands.Create(CreateNewDocument);
            CloseCurrentDocumentCommand = commands.CreateAsync(CloseCurrentDocument);
            ClearErrorCommand           = commands.Create(() => _telemetryProvider.ClearLastError());
            ReportProblemCommand        = commands.Create(ReportProblem);
            EditUserDocumentPathCommand = commands.Create(EditUserDocumentPath);

            _editorFontSize = Properties.Settings.Default.EditorFontSize;

            DocumentRoot = CreateDocumentRoot();

            OpenDocuments = new ObservableCollection <OpenDocumentViewModel>();
            OpenDocuments.CollectionChanged += (sender, args) => OnPropertyChanged(nameof(HasNoOpenDocuments));
        }
Beispiel #3
0
        public void LoadLinks(IArchive linksArchive)
        {
            var links = linksArchive.ReadAll <Archive>();

            foreach (var link in links)
            {
                var input   = link.Read <Archive>(nameof(Link.Input));
                var inNode  = input.Read <Guid>(nameof(Node));
                var inIndex = input.Read <int>("Index");

                var output   = link.Read <Archive>(nameof(Link.Output));
                var outNode  = output.Read <Guid>(nameof(Node));
                var outIndex = output.Read <int>("Index");

                var firstNode  = Nodes.FirstOrDefault(n => n.Id == inNode);
                var secondNode = Nodes.FirstOrDefault(n => n.Id == outNode);

                if (firstNode != null && secondNode != null)
                {
                    if (firstNode.Input.Count > inIndex && secondNode.Output.Count > outIndex)
                    {
                        var inputPin  = firstNode.Input[inIndex];
                        var outputPin = secondNode.Output[outIndex];

                        TryToConnectPins(inputPin, outputPin);
                    }
                    else
                    {
                        _output.Write($"Could not create link in node {outNode}: Input.Index={inIndex} and Output.Index={outIndex}",
                                      _cmdProvider.Create(() => Focus(firstNode)),
                                      OutputType.Warning);
                    }
                }
            }
        }
        public void ToggleBreakpoint(Node node)
        {
            if (node.HasBreakpoint)
            {
                if (!_breakpoints.ContainsKey(node) && _added.Add(node.Id))
                {
                    var brk = new Breakpoint(node, _cmdProvider.Create(() =>
                    {
                        var graphProvider = _provider.Get <IGraphProvider>();

                        graphProvider.OpenInEditor(node.Graph.Id);
                        node.Graph.Focus(node);
                    }));

                    Breakpoints.Add(brk);
                    _breakpoints.Add(node, brk);
                }
            }
            else
            {
                if (_breakpoints.TryGetValue(node, out Breakpoint brk))
                {
                    Breakpoints.Remove(brk);
                    _breakpoints.Remove(node);
                }
            }
        }
        public NuGetDocumentViewModel(NuGetViewModel nuGetViewModel, ICommandProvider commands, ITelemetryProvider telemetryProvider)
        {
            _nuGetViewModel    = nuGetViewModel;
            _telemetryProvider = telemetryProvider;
            _restoreLock       = new SemaphoreSlim(1, 1);

            InstallPackageCommand = commands.Create <PackageData>(InstallPackage);

            Initialize();
        }
Beispiel #6
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public NuGetDocumentViewModel(NuGetViewModel nuGetViewModel, ICommandProvider commands, ITelemetryProvider telemetryProvider)
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            _nuGetViewModel    = nuGetViewModel;
            _telemetryProvider = telemetryProvider;
            _restoreLock       = new SemaphoreSlim(1, 1);
            _libraries         = new HashSet <LibraryRef>();
            _packages          = Array.Empty <PackageData>();
            LocalLibraryPaths  = ImmutableArray <string> .Empty;
            RestoreTask        = Task.CompletedTask;

            InstallPackageCommand = commands.Create <PackageData>(InstallPackage);
        }