本文整理汇总了C#中MahApps.Metro.Controls.MetroWindow.ShowMessageAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MetroWindow.ShowMessageAsync方法的具体用法?C# MetroWindow.ShowMessageAsync怎么用?C# MetroWindow.ShowMessageAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MahApps.Metro.Controls.MetroWindow
的用法示例。
在下文中一共展示了MetroWindow.ShowMessageAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
示例2: ShowDeleteGameStatsMessage
public static async Task<MessageDialogResult> ShowDeleteGameStatsMessage(MetroWindow window, GameStats stats)
{
var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
return
await
window.ShowMessageAsync("Delete Game",
stats.Result + " vs " + stats.OpponentHero + "\nfrom " + stats.StartTime + "\n\nAre you sure?",
MessageDialogStyle.AffirmativeAndNegative, settings);
}
示例3: ShowDeleteMultipleGameStatsMessage
public static async Task<MessageDialogResult> ShowDeleteMultipleGameStatsMessage(MetroWindow window, int count)
{
var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
return
await
window.ShowMessageAsync("Delete Games",
"This will delete the selected games (" + count + ").\n\nAre you sure?",
MessageDialogStyle.AffirmativeAndNegative, settings);
}
示例4: Execute
public async Task<object> Execute( MetroWindow window, object args )
{
ConfirmationServiceArgs csa = args as ConfirmationServiceArgs;
Debug.Assert( csa != null );
MetroDialogSettings settings = new MetroDialogSettings
{
AffirmativeButtonText = csa.OkText,
NegativeButtonText = csa.CancelText
};
var result = await window.ShowMessageAsync( csa.Title, csa.Message, MessageDialogStyle.AffirmativeAndNegative, settings );
return result == MessageDialogResult.Affirmative;
}
示例5: CallMessageModal
public async void CallMessageModal(MetroWindow metroWindow, string title, string message)
{
var metroDialogSettings = new MetroDialogSettings
{
CustomResourceDictionary =
new ResourceDictionary
{
//TODO: Change from default
Source = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
},
NegativeButtonText = "CANCEL",
SuppressDefaultResources = true
};
await metroWindow.ShowMessageAsync(title, message, MessageDialogStyle.Affirmative, metroDialogSettings);
}
示例6: CallAcceptModal
public async Task<bool> CallAcceptModal(MetroWindow metroWindow, string title, string message)
{
var metroDialogSettings = new MetroDialogSettings
{
CustomResourceDictionary =
new ResourceDictionary
{
//TODO: Change from default
Source = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
},
AffirmativeButtonText = "OK",
NegativeButtonText = "CANCEL",
SuppressDefaultResources = true
};
MessageDialogResult userChoice = await metroWindow.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);
var result = userChoice == MessageDialogResult.Affirmative;
return result;
}
示例7: 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.");
}
}