当前位置: 首页>>代码示例>>C#>>正文


C# MetroWindow.ShowProgressAsync方法代码示例

本文整理汇总了C#中MahApps.Metro.Controls.MetroWindow.ShowProgressAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MetroWindow.ShowProgressAsync方法的具体用法?C# MetroWindow.ShowProgressAsync怎么用?C# MetroWindow.ShowProgressAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MahApps.Metro.Controls.MetroWindow的用法示例。


在下文中一共展示了MetroWindow.ShowProgressAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalibrateMagnetometer

        public async void CalibrateMagnetometer(MetroWindow window)
        {
            var controller = await window.ShowProgressAsync("Please wait...", "Setting up Magnetometer Calibration.", true);

            await Task.Delay(3000);
            controller.SetTitle("Magnetometer Calibration");
            for (int i = 0; i < 101; i++)
            {
                controller.SetProgress(i / 100.0);
                controller.SetMessage(string.Format("Rotate the controller in all directions: {0}%", i));

                if (controller.IsCanceled) break;
                await Task.Delay(100);
            }
            await controller.CloseAsync();

            if (controller.IsCanceled)
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration has been cancelled.");
            }
            else
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration finished successfully.");
            }
        }
开发者ID:cosmo1911,项目名称:UniMoveStation,代码行数:25,代码来源:DesignMotionControllerService.cs

示例2: Execute

		public async Task<object> Execute( MetroWindow window, object args )
		{
			ProgressServiceArgs psa = args as ProgressServiceArgs;
			Debug.Assert( psa != null );

			var controller = await window.ShowProgressAsync( Strings.PleaseWait, Strings.MovingDatabase );
			var report = new ProgressReport( controller );

			await Task.Run( () =>
			{
				psa.Action( report );
			} );

			await controller.CloseAsync();

			return null;
		}
开发者ID:TheSylence,项目名称:GSD,代码行数:17,代码来源:ProgressService.cs

示例3: StartMagnetometerCalibrationTask

        public async void StartMagnetometerCalibrationTask(MetroWindow window)
        {
            CancelUpdateTask();
            _ctsMagnetometerCalibration = new CancellationTokenSource();
            var controller = await window.ShowProgressAsync("Magnetometer Calibration", null, true);
            CancellationToken token = _ctsMagnetometerCalibration.Token;
            try
            {
                await Task.Run(() =>
                {
                    PsMoveApi.psmove_reset_magnetometer_calibration(_motionController.Handle);
                    int oldRange = 0;
                    bool calibrationFinished = false;
                    Color color = _motionController.Color;
                    while (!token.IsCancellationRequested && !calibrationFinished)
                    {
                        while (PsMoveApi.psmove_poll(_motionController.Handle) > 0)
                        {
                            float ax, ay, az;
                            PsMoveApi.psmove_get_magnetometer_vector(_motionController.Handle, out ax, out ay, out az);

                            int range = PsMoveApi.psmove_get_magnetometer_calibration_range(_motionController.Handle);
                            MagnetometerCalibrationProgress = 100*range/320;
                            if (MagnetometerCalibrationProgress > 100) MagnetometerCalibrationProgress = 100;
                            else if (MagnetometerCalibrationProgress < 0) MagnetometerCalibrationProgress = 0;
                            controller.SetProgress(MagnetometerCalibrationProgress/100.0);

                            float r = (color.r/100)*MagnetometerCalibrationProgress;
                            float g = (color.g/100)*MagnetometerCalibrationProgress;
                            float b = (color.b/100)*MagnetometerCalibrationProgress;
                            SetLED(new Color(r, g, b));
                            PsMoveApi.psmove_update_leds(_motionController.Handle);

                            if (controller.IsCanceled)
                            {
                                CancelMagnetometerCalibrationTask();
                            }

                            if (range >= 320)
                            {
                                if (oldRange > 0)
                                {
                                    PsMoveApi.psmove_save_magnetometer_calibration(_motionController.Handle);
                                    calibrationFinished = true;
                                    break;
                                }
                            }
                            else if (range > oldRange)
                            {
                                controller.SetMessage(string.Format("Rotate the controller in all directions: {0}%...",
                                    MagnetometerCalibrationProgress));
                                oldRange = range;
                            }
                        }
                    }
                });
            }
            catch (OperationCanceledException)
            {

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            await controller.CloseAsync();
            if (controller.IsCanceled)
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration has been cancelled.");
            }
            else
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration finished successfully.");
            }
        }
开发者ID:cosmo1911,项目名称:UniMoveStation,代码行数:76,代码来源:MotionControllerService.cs


注:本文中的MahApps.Metro.Controls.MetroWindow.ShowProgressAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。