public void DisplayVignette(VignetteVideoConfig config, FinishedAction finishedAction)
    {
        m_FinishedAction = finishedAction;

        GatherAndPauseAllPlayingAudioSources();

        m_Config               = config;
        currentIndex           = 0;
        furthestSeenIndex      = 0;
        m_Finished             = false;
        m_FiredFinishingAction = false;

        m_TimeSinceStarted = 0;

        m_TextSpeed = config.TextSpeed;

        // visuals configs
        m_Background.sprite     = m_Config.Background;
        m_BackgroundColor.color = m_Config.BackgroundColor;
        RectTransform bgRectTransform = ((RectTransform)m_Background.transform);

        bgRectTransform.anchoredPosition = m_Config.BackgroundImageOffset;

        if (m_Config.BackgroundScale == 0)
        {
            m_Config.BackgroundScale = 1;
        }
        bgRectTransform.localScale = Vector3.one * m_Config.BackgroundScale;

        m_Text.font        = m_Config.Font;
        m_Text.fontSize    = m_Config.FontSize;
        m_Text.lineSpacing = m_Config.LineSpacing;
        if (m_Config.PlayAudioSource)
        {
            GameManager.Instance.PlayAudioSource(m_Config.AudioSourceToPlay);
            GameManager.Instance.SetAudioSourceVolume(config.InitialMusicVolume);
            m_TargetAudioSourceVolume = config.InitialMusicVolume;
        }

        RectTransform rectTransform = ((RectTransform)m_Text.transform);

        rectTransform.anchoredPosition = m_Config.TextOffset;
        rectTransform.sizeDelta        = new Vector2(m_Config.TextBoxWidth, rectTransform.sizeDelta.y);

        m_ReadyToAdvanceAnimation.alpha = config.HideAdvanceIndicator ? 0 : 1;

        m_BackgroundVideo = config.m_BackgroundVideo;
        if (m_BackgroundVideo != null)
        {
            m_BackgroundVideo.StartScriptable();
        }

        StartFade(m_Config.FadeIn, m_Config.FadeInCurve, m_Config.FadeInColor);
        DisplayStep(currentIndex);
    }
        //This runs on the source connection
        public async Task Sync()
        {
            var errors = new List <Exception>();

            //Make sure we're only syncing once at a time
            //since this is async, have to use Semaphore
            if (await semaphore.WaitAsync(0))
            {
                try
                {
                    if (CheckSyncNeeded != null)
                    {
                        var result = await CheckSyncNeeded(this, completeStatusValue);

                        if (!result)
                        {
                            Log?.Invoke("Nothing to sync");
                            return;
                        }
                    }
                    //Make new list to allow removal of broken models
                    foreach (var model in new List <ISyncModel>(models))
                    {
                        try
                        {
                            //Load items that need sync
                            var itemsToSync = await model.LoadItemsNeedingSync(this);

                            if (!itemsToSync)
                            {
                                models.Remove(model);
                            }
                        }
                        catch (Exception ex)
                        {
                            errors.Add(new Exception("Error occurred during item load", ex));
                            models.Remove(model);
                        }
                    }

                    if (models.Count == 0)
                    {
                        Log?.Invoke("Nothing to sync");
                        return;
                    }

                    var syncTasks = new List <Task>();
                    for (int x = 0; x < targetConnectionStrings.Count; x++)
                    {
                        syncTasks.Add(SyncToTarget(targetConnectionStrings[x], x));
                    }
                    var whenAll = Task.WhenAll(syncTasks);
                    try
                    {
                        await whenAll;
                    }
                    catch
                    {
                        var aggregate = whenAll.Exception;
                        errors.AddRange(whenAll.Exception.InnerExceptions);
                    }
                    foreach (var model in models)
                    {
                        try
                        {
                            model.UpdateStatuses();
                            errors.AddRange(model.Errors);
                        }
                        catch (Exception ex)
                        {
                            errors.Add(new Exception("Error occurred during status update", ex));
                        }
                    }
                    FinishedAction?.Invoke();
                    await SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    errors.Add(ex);
                }
                finally
                {
                    semaphore.Release();
                }
            }

            if (errors.Count > 0)
            {
                throw new AggregateException("Errors occurred: ", errors);
            }
        }
示例#3
0
        private void btnAddService_Click(object sender, RoutedEventArgs e)
        {
            Dispatcher.VerifyAccess();
            try
            {
                Project project        = ((ProjectInfo)LanguageMap.Current.GetActiveProject()).Project;
                string  projectPath    = project.FullName;
                string  servicesFolder = Path.Combine(Path.GetDirectoryName(projectPath), "Connected Services");
                if (!Directory.Exists(servicesFolder))
                {
                    project.ProjectItems.AddFolder("Connected Services");
                }
                Uri    uri = null;
                string serviceNameSpace = txtServiceName.Text.Trim();
                string serviceURI       = txtServiceAddress.Text.Trim();
                if (string.IsNullOrEmpty(serviceNameSpace))
                {
                    MessageBox.Show("Please fill your service name", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else if (!Uri.TryCreate(serviceURI, UriKind.Absolute, out uri))
                {
                    MessageBox.Show("Service address is not true", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string servicePath = Path.Combine(servicesFolder, Path.GetFileNameWithoutExtension(serviceNameSpace));
                if (!Directory.Exists(servicePath))
                {
                    Directory.CreateDirectory(servicePath);
                }
                AddReferenceConfigInfo config = new AddReferenceConfigInfo
                {
                    ServiceUrl                       = serviceURI,
                    ServiceNameSpace                 = serviceNameSpace,
                    LanguageType                     = cboLanguage.SelectedIndex,
                    ServiceType                      = cboServiceType.SelectedIndex,
                    IsGenerateAsyncMethods           = chkAsyncMethods.IsChecked.Value,
                    IsJustGenerateServices           = chkJustServices.IsChecked.Value,
                    IsAutomaticSyncAndAsyncDetection = rdoIsAutomaticDetection.IsChecked.Value,
                    ReplaceNameSpaces                = ReplaceNameSpaces.ToList(),
                    SkipAssemblies                   = SkipAssemblies.ToList(),
                    CustomNameSpaces                 = customNameSpaces.Text
                };

                string fullFilePath = LanguageMap.Current.DownloadService(servicePath, config);


                string signalGoSettingPath = Path.Combine(servicePath, "setting.signalgo");
                File.WriteAllText(signalGoSettingPath, JsonConvert.SerializeObject(config), Encoding.UTF8);

                if (!string.IsNullOrEmpty(fullFilePath))
                {
                    project.ProjectItems.AddFromFile(fullFilePath);
                }
                FinishedAction?.Invoke();
                MessageBox.Show($"Service {serviceNameSpace} generated", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }