Exemple #1
0
        public static CancellationTokenSource ShowLoad(string message, Panel parent = null)
        {
            var tokenSource = new CancellationTokenSource();

            if (parent == null)
            {
                parent = Utils.GetMainWindowPanel();
            }

            parent.Dispatcher.BeginInvoke((Action)(() =>
            {
                var messageView = new MessageView();
                messageView.ContentText = message;
                messageView.HeaderText = "Пожалуйста, подождите...";
                messageView.Icon = Icons.Icon.MoonSleep;
                messageView.StartAnimateProgress();
                messageView.Show(parent);

                tokenSource.Token.Register(() => messageView.Dispatcher.BeginInvoke(new Action(() =>
                {
                    messageView.Close();
                })));
            }));

            return(tokenSource);
        }
        public static LoadingViewCancellation ShowLoad(string message, Panel parent = null)
        {
            if (parent == null)
            {
                parent = Utils.GetMainWindowPanel();
            }

            var loadingCancellation = new LoadingViewCancellation();

            parent.Dispatcher.BeginInvoke(new Action(() =>
            {
                var messageView         = new MessageView();
                messageView.ContentText = message;
                messageView.HeaderText  = "Пожалуйста, подождите...";
                messageView.Icon        = Icon.MoonSleep;
                messageView.StartAnimateProgress();
                messageView.Show(parent);
                loadingCancellation.Register(() => messageView.Dispatcher.BeginInvoke((Action)messageView.Close));
            }));

            return(loadingCancellation);
        }