Ejemplo n.º 1
0
 private void GetDataFromDb()
 {
     try
     {
         Settings = SettingsLogic.ReadConfiguration();
         string conString = $"Data Source={Settings.ConnectionString.DataSource}" +
                            $"AttachDbFilename = {Settings.ConnectionString.AttachDbFilename}" +
                            $"Integrated Security = {Settings.ConnectionString.IntegratedSecurity}";
         db = new DataContext(conString);
         firstNamesFromDb.AddRange(db.FirstNames);
         secondNamesFromDb.AddRange(db.SecondNames);
         if (firstNamesFromDb.Count == 0 || secondNamesFromDb.Count == 0)
         {
             this.Invoke(new Action(() => AskForData()));
         }
     }
     catch (InvalidOperationException)
     {
         throw;
     }
     catch (SqlException)
     {
         this.Invoke(new Action(() => AskForData()));
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Произошла ошибка\n{ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     ButtonUserGenerate.Invoke(new Action(() => { ButtonUserGenerate.Enabled = true; }));
     LoadIndicator.Invoke(new Action(() => { LoadIndicator.Hide(); }));
 }
Ejemplo n.º 2
0
        private void Init()
        {
            var blur = CreateChild <BlurDisplay>("blur", 0);

            {
                blur.Anchor = AnchorType.Fill;
                blur.Offset = Offset.Zero;

                var dark = blur.CreateChild <UguiSprite>("dark", 0);
                {
                    dark.Anchor = AnchorType.Fill;
                    dark.Offset = Offset.Zero;
                    dark.Color  = new Color(0f, 0f, 0f, 0.75f);
                }
            }
            infoDisplayer = CreateChild <InfoDisplayer>("info", 1);
            {
            }
            loadIndicator = CreateChild <LoadIndicator>("load", 2);
            {
                loadIndicator.Position = new Vector3(0f, -260f);
                loadIndicator.Size     = new Vector2(88f, 88f);
            }

            float showDur = Mathf.Max(infoDisplayer.ShowAniDuration, loadIndicator.ShowAniDuration);

            componentShowAni = new Anime();
            componentShowAni.AddEvent(0f, () =>
            {
                infoDisplayer.Show();
                loadIndicator.Show();
            });
            componentShowAni.AddEvent(showDur + model.MinimumLoadTime, OnShowAniEnd);

            float hideDur = Mathf.Max(infoDisplayer.HideAniDuration, loadIndicator.HideAniDuration);

            componentHideAni = new Anime();
            componentHideAni.AddEvent(0f, () =>
            {
                infoDisplayer.Hide();
                loadIndicator.Hide();
            });
            componentHideAni.AnimateFloat(v => model.MusicController.SetFade(v))
            .AddTime(0f, 0.5f, EaseType.QuadEaseOut)
            .AddTime(hideDur, 0f)
            .Build();
            componentHideAni.AddEvent(hideDur, () =>
            {
                model.MusicController.SetFade(1f);
                OnHideAniEnd();
            });

            OnEnableInited();
        }