Beispiel #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(); }));
 }
Beispiel #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();
        }
Beispiel #3
0
        void StartLoadingAnimated(bool animated)
        {
            LoadIndicator.StartAnimating();

            UIView.Animate((animated) ? 0.2 : 0.0,
                           () =>
            {
                ImageView.Alpha     = 0f;
                LoadIndicator.Alpha = 1f;
            });
        }
Beispiel #4
0
        protected static void DemoLoadIndicator()
        {
            CoEx.WriteTitleLarge("Loading indicator");
            CoEx.WriteLine();

            LoadIndicator indicator = new LoadIndicator()
            {
                Message = "Load the awesomeness"
            };

            indicator.Start();
            System.Threading.Thread.Sleep(5000);
            indicator.Stop();
        }
Beispiel #5
0
        public RamemForm()
        {
            InitializeComponent();
            LoadIndicator.Show();
            Thread getData = new Thread(GetDataFromDb);

            try
            {
                getData.Start();
            }
            catch (InvalidOperationException)
            {
                throw;
            }
        }
Beispiel #6
0
        static async Task RunAsync(QueryProvider provider, CancellationToken cancellationToken = default)
        {
            WriteTitle(provider.ToString());
            WriteLine($"Count AB: {Count(provider, "AB")}");
            var indicator = new LoadIndicator();

            indicator.Start();
            RowCollection?table = Load(provider, "AB");

            indicator.Stop();
            WriteTable(table);
            PressAnyKey();
            WriteLine($"Count PQ: {await CountAsync(provider, "PQ").ConfigureAwait(false)}");
            indicator.Start();
            table = await LoadAsync(provider, "PQ", cancellationToken).ConfigureAwait(false);

            indicator.Stop();
            WriteTable(table);
            PressAnyKey();
        }
Beispiel #7
0
        public void SetOriginalImage(UIImage originalImage, CGRect cropFrame)
        {
            LoadIndicator.StartAnimating();
            InvokeOnMainThread(() =>
            {
                CGImage imageRef = originalImage.CGImage;
                UIImageOrientation imageOrientation = originalImage.Orientation;

                if (imageRef == null)
                {
                    return;
                }


                var bytesPerRow          = 0;
                var width                = imageRef.Width;
                var height               = imageRef.Height;
                var bitsPerComponent     = imageRef.BitsPerComponent;
                CGColorSpace colorSpace  = CGColorSpace.CreateDeviceRGB();
                CGBitmapFlags bitmapInfo = imageRef.BitmapInfo;

                switch (imageOrientation)
                {
                case UIImageOrientation.RightMirrored:
                case UIImageOrientation.LeftMirrored:
                case UIImageOrientation.Right:
                case UIImageOrientation.Left:
                    width  = imageRef.Height;
                    height = imageRef.Width;
                    break;

                default:
                    break;
                }

                CGSize imageSize        = new CGSize(width, height);
                CGBitmapContext context = new CGBitmapContext(null,
                                                              width,
                                                              height,
                                                              bitsPerComponent,
                                                              bytesPerRow,
                                                              colorSpace,
                                                              bitmapInfo);

                colorSpace.Dispose();

                if (context == null)
                {
                    imageRef.Dispose();
                    return;
                }

                switch (imageOrientation)
                {
                case UIImageOrientation.RightMirrored:
                case UIImageOrientation.Right:
                    context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                    context.RotateCTM(-((nfloat)Math.PI / 2));
                    context.TranslateCTM(-imageSize.Height / 2, -imageSize.Width / 2);
                    break;

                case UIImageOrientation.LeftMirrored:
                case UIImageOrientation.Left:
                    context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                    context.RotateCTM((nfloat)(Math.PI / 2));
                    context.TranslateCTM(-imageSize.Height / 2, -imageSize.Width / 2);
                    break;

                case UIImageOrientation.Down:
                case UIImageOrientation.DownMirrored:
                    context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                    context.RotateCTM((nfloat)Math.PI);
                    context.TranslateCTM(-imageSize.Width / 2, -imageSize.Height / 2);
                    break;

                default:
                    break;
                }

                context.InterpolationQuality = CGInterpolationQuality.High;
                context.SetBlendMode(CGBlendMode.Copy);
                context.DrawImage(new CGRect(0, 0, imageRef.Width, imageRef.Height), imageRef);

                CGImage contextImage = context.ToImage();

                context.Dispose();

                if (contextImage != null)
                {
                    _originalImage = UIImage.FromImage(contextImage, originalImage.CurrentScale, UIImageOrientation.Up);

                    contextImage.Dispose();
                }

                imageRef.Dispose();

                BeginInvokeOnMainThread(() =>
                {
                    CGSize convertedImageSize = new CGSize(_originalImage.Size.Width / _cropSizeRatio,
                                                           _originalImage.Size.Height / _cropSizeRatio);

                    ImageView.Alpha = 0;
                    ImageView.Image = _originalImage;

                    CGSize sampleImageSize = new CGSize(Math.Max(convertedImageSize.Width, ScrollView.Frame.Size.Width),
                                                        Math.Max(convertedImageSize.Height, ScrollView.Frame.Size.Height));

                    ScrollView.MinimumZoomScale = 1;
                    ScrollView.MaximumZoomScale = 1;
                    ScrollView.ZoomScale        = 1;
                    ImageView.Frame             = new CGRect(0, 0, convertedImageSize.Width, convertedImageSize.Height);

                    nfloat zoomScale = 1;

                    if (convertedImageSize.Width < convertedImageSize.Height)
                    {
                        zoomScale = (ScrollView.Frame.Size.Width / convertedImageSize.Width);
                    }
                    else
                    {
                        zoomScale = (ScrollView.Frame.Size.Height / convertedImageSize.Height);
                    }

                    ScrollView.ContentSize = sampleImageSize;

                    if (zoomScale < 1)
                    {
                        ScrollView.MinimumZoomScale = zoomScale;
                        ScrollView.MaximumZoomScale = 1;
                        ScrollView.ZoomScale        = zoomScale;
                    }
                    else
                    {
                        ScrollView.MinimumZoomScale = zoomScale;
                        ScrollView.MaximumZoomScale = zoomScale;
                        ScrollView.ZoomScale        = zoomScale;
                    }

                    ScrollView.ContentInset  = UIEdgeInsets.Zero;
                    ScrollView.ContentOffset = new CGPoint((ImageView.Frame.Size.Width - ScrollView.Frame.Size.Width) / 2, (ImageView.Frame.Size.Height - ScrollView.Frame.Size.Height) / 2);
                    if (cropFrame.Size.Width > 0 && cropFrame.Size.Height > 0)
                    {
                        nfloat scale        = UIScreen.MainScreen.Scale;
                        nfloat newZoomScale = (_targetSize.Width * scale) / cropFrame.Size.Width;

                        ScrollView.ZoomScale = newZoomScale;

                        nfloat heightAdjustment = (_targetSize.Height / _cropSizeRatio) - ScrollView.ContentSize.Height;
                        nfloat offsetY          = cropFrame.Y + (heightAdjustment * _cropSizeRatio * scale);

                        ScrollView.ContentOffset = new CGPoint(cropFrame.X / scale / _cropSizeRatio,
                                                               (offsetY / scale / _cropSizeRatio) - heightAdjustment);
                    }

                    ScrollView.SetNeedsLayout();

                    UIView.Animate(0.3,
                                   () =>
                    {
                        LoadIndicator.Alpha = 0;
                        ImageView.Alpha     = 1;
                    }, () =>
                    {
                        LoadIndicator.StopAnimating();
                    });
                });
            });
        }