Пример #1
0
        private UpdateDialogModel CreateUpdateDialogModel(IViewModel?parent, IUpdateResult updateResult)
        {
            if (updateResult == null)
            {
                throw new ArgumentNullException(nameof(updateResult));
            }

            var dialogModel = new UpdateDialogModel
            {
                Parent               = parent,
                Title                = Strings.UpdateAvailable,
                CurrentVersion       = updateResult.CurrentVersion,
                UpdateVersion        = updateResult.NewestVersion,
                UpdateUri            = updateResult.NewestVersionUri,
                ReleaseTag           = updateResult.ReleaseTag,
                OpenUpdateUriCommand = new OpenUpdateUriCommand(_uriService),
                InstallUpdateCommand = new InstallUpdateCommand(_installService, _ioService, _downloadFolderPath),
                CancelUpdateCommand  = new CancelUpdateCommand(),
                IsDirty              = false
            };

            foreach (var updateAsset in updateResult.UpdateAssets)
            {
                dialogModel.UpdateAssets.Add(CreateUpdateAssetViewModel(dialogModel, updateAsset));
            }
            return(dialogModel);
        }
Пример #2
0
        private void LibAtemReceive(object sender, IReadOnlyList <byte[]> commands)
        {
            lock (_libAtemStateLock)
            {
                foreach (byte[] cmdBytes in commands)
                {
                    // It should be safe to assume exactly one per
                    ParsedCommand.ReadNextCommand(cmdBytes, 0, out ParsedCommandSpec? cmd);
                    if (cmd == null)
                    {
                        throw new Exception("Failed to parse command");
                    }

                    ICommand cmd2 = CommandParser.Parse(_mockServer.CurrentVersion, cmd.Value);
                    if (cmd2 == null)
                    {
                        throw new Exception("Failed to parse command2");
                    }

                    OnLibAtemCommand?.Invoke(this, cmd2);

                    // TODO - handle result?
                    IUpdateResult result = AtemStateBuilder.Update(_libAtemState, cmd2, StateSettings);
                    foreach (string change in result.ChangedPaths)
                    {
                        OnLibAtemStateChange?.Invoke(this, change);
                    }
                }
            }
        }